package com.av.record.views;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.drawable.Drawable;
import java.lang.reflect.Field;

public class Res {
    private static String pkgName;
    private static Resources resources;
    private static Context mContext;

    public Res() {
    }

    public static void init(Context context) {
        mContext = context;
        pkgName = context.getPackageName();
        resources = context.getResources();
    }

    public static int getLayoutID(String layoutName) {
        return resources.getIdentifier(layoutName, "layout", pkgName);
    }

    public static int getWidgetID(String widgetName) {
        return resources.getIdentifier(widgetName, "id", pkgName);
    }

    public static int getAnimID(String animName) {
        return resources.getIdentifier(animName, "anim", pkgName);
    }

    public static int getXmlID(String xmlName) {
        return resources.getIdentifier(xmlName, "xml", pkgName);
    }

    public static XmlResourceParser getXml(String xmlName) {
        int xmlId = getXmlID(xmlName);
        return resources.getXml(xmlId);
    }

    public static int getRawID(String rawName) {
        return resources.getIdentifier(rawName, "raw", pkgName);
    }

    public static int getDrawableID(String drawName) {
        return resources.getIdentifier(drawName, "drawable", pkgName);
    }

    public static int getMipMapID(String drawName) {
        return resources.getIdentifier(drawName, "mipmap", pkgName);
    }

    public static Drawable getDrawable(String drawName) {
        int drawId = getDrawableID(drawName);
        return resources.getDrawable(drawId);
    }

    public static int getAttrID(String attrName) {
        return resources.getIdentifier(attrName, "attr", pkgName);
    }

    public static int getDimenID(String dimenName) {
        return resources.getIdentifier(dimenName, "dimen", pkgName);
    }

    public static int getDimensID(String dimenName) {
        return resources.getIdentifier(dimenName, "dimens", pkgName);
    }

    public static int getColorID(String colorName) {
        return resources.getIdentifier(colorName, "color", pkgName);
    }

    public static int getColor(String colorName) {
        return resources.getColor(getColorID(colorName));
    }

    public static int getStyleID(String styleName) {
        return resources.getIdentifier(styleName, "style", pkgName);
    }

    public static int getStringID(String strName) {
        return resources.getIdentifier(strName, "string", pkgName);
    }

    public static String getString(String strName) {
        int strId = getStringID(strName);
        return resources.getString(strId);
    }

    public static int[] getInteger(String strName) {
        return resources.getIntArray(resources.getIdentifier(strName, "array", pkgName));
    }

    public static String[] getStringArray(String strName) {
        return resources.getStringArray(resources.getIdentifier(strName, "array", pkgName));
    }

    public static final int[] getStyleableIntArray(String name) {
        try {
            if (mContext == null) {
                return null;
            } else {
                Field field = Class.forName(mContext.getPackageName() + ".R$styleable").getDeclaredField(name);
                int[] ret = (int[])((int[])field.get((Object)null));
                return ret;
            }
        } catch (Throwable var3) {
            return null;
        }
    }

    public static final int getStyleableIntArrayIndex(String name) {
        try {
            if (mContext == null) {
                return 0;
            } else {
                Field field = Class.forName(mContext.getPackageName() + ".R$styleable").getDeclaredField(name);
                int ret = (Integer)field.get((Object)null);
                return ret;
            }
        } catch (Throwable var3) {
            return 0;
        }
    }
}
